package net.m510.autosurfer.mhbk;

import java.net.URI;
import java.util.List;
import java.util.logging.Logger;

import net.m510.autosurfer.common.DocumentPostProcess;
import net.m510.autosurfer.core.Parameters;

import org.apache.http.NameValuePair;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.FormElement;

/**
 * @author mgoto
 *
 */
public class MhbkGoDownload extends DocumentPostProcess {
	private static final Logger log = Logger.getLogger(MhbkGoDownload.class.getName());

	public MhbkGoDownload() {
		this(null,null);
	}
	public MhbkGoDownload(CloseableHttpClient client, HttpClientContext context) {
		super(client, context);
		super.log = log;
	}
	@Override
	protected URI getUri(Document doc) {
		URI uri = URI.create(context.getTargetHost().toURI());
		return uri.resolve("/servlet/MENSRV0100003B.do");
	}
	@Override
	protected List<NameValuePair> getRequestParameters(Document doc) {
		FormElement form = doc.getAllElements().forms().get(0);
		Parameters p = Parameters.create(form);
		return p.asNameValueList();
	}

}